package com.tangcan.blog.Controller;


import com.alibaba.fastjson.JSONObject;
import com.tangcan.blog.Service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/Api/Comment")
@EnableAutoConfiguration
@CrossOrigin(origins = "*",maxAge = 3600 ,allowCredentials="true")
public class CommentController {
    @Autowired
    CommentService commentService;
    @RequestMapping(value = "/GetAll",method = RequestMethod.GET)
    @ResponseBody
    public JSONObject GetAll(){
        return commentService.GetAll();
    }

    @RequestMapping(value = "/GetByBlogId",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject GetByBlogId(@RequestBody String data){
        return commentService.GetByBlogId(data);
    }
    @RequestMapping(value = "/GetById",method = RequestMethod.POST)
    @ResponseBody
    public  JSONObject GetById(@RequestBody String  data)
    {
        return commentService.GetById(data);
    }

    @RequestMapping(value = "/AddComment",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject AddComment(@RequestBody String data)
    {
        return commentService.AddComment(data);
    }
    @RequestMapping(value = "/UpdateComment",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject UpdateComment(@RequestBody String data)
    {
        return commentService.UpdateComment(data);
    }


    @RequestMapping(value = "/RemoveComment",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject RemoveComment(@RequestBody String data)
    {return commentService.RemoveComment(data);
    }
}
